<?php
$page_title = 'eTAT';
require_once 'library/Controller.php';

if($params->c != '') {
	$course = $instructor->getCourse($params->c);
	$groups = $course->getAllGroups();
} else 
	redirect('home.php');

if(isset($_POST['add_group_submit'])) {
	unset($_SESSION['add_project']);
	$_SESSION['add_project']->course = $course->id;
	$_SESSION['add_project']->step = 0;
	redirect('addGroup.php');
}

require_once 'Header.php';
?>
<h1><?php print $course->title ?></h1>
<div id='parser-update' class='invisible'></div>
<h3>Groups:</h3>
<?php 
if(isset($groups)) {
	foreach($groups as $g) {
		print "<a href='group.php?g=$g->id'>$g->name</a><br>";
	}
} else {
?>
<p>Looks like you haven't added any groups for monitoring, yet.</p>
<p>Let's get started by pressing the <b>Add Group</b> button below:</p>
<?php 
}
$form = new Form('add_group_form','post');
$form->button('add_group_submit','Add Group',array('type'=>'submit'));
print $form->build();
?>

<div class='clear'></div>
<?php require_once 'Footer.php'; ?>